package src.iteitma0A;

import java.util.ArrayList;

public class A {
    public static void main(String[] args) {
        ArrayList<Worker> arrayList=new ArrayList();
        arrayList.add(new Worker("hahah", 10));
        arrayList.add(new Worker("2121", 20));

        ArrayList<Person> arrayList1=new ArrayList();
        arrayList1.add(new Person(20,"155"));
        arrayList1.add(new Person(30,"jjj"));

        ArrayList<Integer> arrayList2=new ArrayList();
        arrayList2.add(100);
        arrayList2.add(300);

        method(arrayList);
        method(arrayList1);
        method(arrayList2);

        ArrayList<JavaTeacher>arrayList3=new ArrayList();
        arrayList3.add(new JavaTeacher("20",12));

        method01(arrayList3);
        //method02(arrayList3)；报错因为Java是他的子类不是他的父类要放入父类

    }

    public static  void  method(ArrayList<?> arrayList){
        for (Object o : arrayList) {
            System.out.println(o);
        }
    }
    public  static  void  method01(ArrayList<? extends Person> arrayList){
        for (Object o : arrayList) {
            System.out.println(o);
        }
    }

    public  static  void  method02(ArrayList<? super  Teacher> arrayList){
        for (Object o : arrayList) {
            System.out.println(arrayList);
        }
    }
}
